import { createStore } from "vuex";
import persist from "vuex-persistedstate"
export default createStore({
    state: {
        tasks: []
    },
    mutations: {
        // 添加任务的方法
        addTask(state, task) {
            let obj = {
                task,
                check: false,
                id: new Date().getTime(),
                exit: false,
                state: "work" // work表示正在进行的任务 finish表示已经完成的任务
            }
            state.tasks.push(obj)
        },

        changeTasks(state, tasks) {
            state.tasks = tasks
        },

        del(state, i) {
            state.tasks.splice(i, 1)
        }
    },
    plugins: [persist()]
});